import pandas as pd
import numpy as np
import seaborn
import matplotlib as mpl
import matplotlib.pyplot as plt

'''
#=====折线图=====#
mpl.rcParams['font.sans-serif']=['SimHei']
tra_accuracy=[0.12,0.23,0.31,0.34,0.43,0.51,0.55,0.66,0.68,0.74,0.8,0.9]
test_acc = [0.4,0.5,0.6,0.7,0.8,0.9]

plt.plot(np.linspace(0, 11, len(tra_accuracy)),tra_accuracy,'b-',label='训练的正确率')
plt.plot(np.linspace(0, 10, len(test_acc)),test_acc,'k-.',label='测试的正确率')
plt.title('训练、测试的正确率')
plt.xlabel('迭代次数')
plt.ylabel('准确率')
plt.legend(loc='lower right')
'''

'''
#=====柱状图=====#
#字体为中文，大小13
plt.rc('font', family='SimHei', size=13)

num = np.array([13325, 9403, 9227, 8651])
ratio = np.array([0.75, 0.76, 0.72, 0.75])
men = num * ratio
women = num * (1 - ratio)
x = ['聊天', '支付', '团购\n优惠券', '在线视频']

width = 0.5
idx = np.arange(len(x))
plt.bar(idx, men, width, color='red', label='男性用户')
plt.bar(idx, women, width, bottom=men, color='yellow', label='女性用户',align='center',alpha=1)
#alpha为对比度
plt.xlabel('应用类别')
plt.ylabel('男女分布')
#x横坐标显示
plt.xticks(idx , x, rotation=10)
plt.legend()
plt.show()
'''

'''
#=====散点图===#
x=np.array([1,2,3,4,5])
y=np.array([1,4,9,16,25])
z=['yican','ercan','sancan','sican','wucan']
#s点的大小，c颜色，alpha为对比度
plt.scatter(x,y,s=500,c='red',alpha=0.5)
#标签
plt.xlabel('shuzi')
plt.ylabel('pingfang')
#坐标轴显示
plt.xticks(x,z)
#坐标轴范围
#plt.xlim((1,3))
#plt.ylim(0,9)
plt.show()
'''

#=====饼状图=====#
plt.rc('font', family='SimHei', size=13)
data=[8,25,13,20,4]
#各饼之间有间隔
explode=(0,0.3,0,0.1,0)
colors=['red','yellow','blue','tomato','green']
labels=['5-10','25-30','10-15','15-20','0-5']
#数字格式autopct='%1.3f%%',文字格式textprops={'fontsize':15,'color':'white'}
plt.pie(data,explode=explode,labels=labels,colors=colors,autopct='%1.3f%%',textprops={'fontsize':15,'color':'white'},)
#图例靠右
plt.axis('equal')
plt.title('饼状图')
plt.legend(loc='upper right')
plt.show()